/*
 * psMqtt.h
 *
 *  Created on: Nov 16, 2021
 *      Author: tau
 */

#ifndef SRV_NET_PSMQTT_H_
#define SRV_NET_PSMQTT_H_


#include "cjson/cJSON.h"
#include "MQTTClient.h"
#include "stddef.h"
#include "stdio.h"
#include "string.h"

typedef struct{
    char host[128];
    char pubTopic[32];
    char subTopic[32];
    char clientID[32];
    char user[32];
    char password[32];

}mqttConnctionnBase_t;

typedef struct{
    MQTTClient client;

    MQTTClient_deliveryToken token[2];
}mqttClientBase_t;


class psMqtt {
private:
    cJSON* json;
    mqttConnctionnBase_t mcb;
    mqttClientBase_t mClientb;
    bool isConnected;
    int readConfig(void);
    int createMqttClient(void);
    static void*  background(void* arg);
public:
	psMqtt();
	virtual ~psMqtt();
	int sendMsg(char* data);
};

#endif /* SRV_NET_PSMQTT_H_ */
